#
# 远程命令, 给as和java端用
#

import os
import os.path

msg="""
ERROR
LOGIN
QUERY_CITY_ON_MAP
QUERY_CITY_DETAIL
QUERY_CHUZHENG_MAN_LIST
QUERY_BUSHU_MAN_LIST
QUERY_JICE_MAN_LIST
QUERY_CHUZHENG_MAN_DETAIL
QUERY_BUSHU_MAN_DETAIL
QUERY_JICE_MAN_DETAIL
QUERY_ARMY_DETAIL
QUERY_ARMY_SETUP
QUERY_ARMY_ON_MAP
UPDATE_ARMY_DISBAND
UPDATE_ARMY_ARRIVED
UPDATE_ARMY_MOVE
UPDATE_USER_LOCATION
"""

file = None

def p(*msg):
    global file
    print(*msg)
    print(*msg,file=file)

def main():
    mm = msg.split()

    path = '../../../client/src/com/showgood/vo/'
    if not os.path.exists(path):
        os.makedirs(path)
    gen_as3(path, mm)

    path = '../../src/java/com/showgood/vo/'
    if not os.path.exists(path):
        os.makedirs(path)
    gen_java(path, mm)


def gen_as3(path, mm):
    global file
    path = path + 'RemoteMessage.as'
    file = open(path, 'w')
    p('package com.showgood.vo { public class RemoteMessage {')
    id=1
    p('public static const REMOTE_START:int = 0x00010000;')
    for m in mm:
      p('public static const', 'REMOTE_'+m, ':int = REMOTE_START +', id,';')
      id+=1
    p('}\n}')
    file.close()

def gen_java(path, mm):
    global file
    path = path + 'RemoteMessage.java'
    file = open(path, 'w')
    p('package com.showgood.vo;')
    p('public interface RemoteMessage{')
    id=1
    p('int REMOTE_START = 0x00010000;')
    for m in mm:
        p('int', 'REMOTE_'+m, '= REMOTE_START +',id,';')
        id+=1
    p('}')
    file.close()    


if __name__ == '__main__':
    main()

    
